import type { PageParams } from "@/types/common"
import type {  Role, RoleData, RoleDetail, RoleParams, RoleUserData } from "@/types/system"
import { request } from "@/utils/reuqest"

/**
 * 获取角色列表
 * @returns
 */
export const getRoleListAPI=()=>{
    return request<Role[]>('/park/sys/role')
}
/**
 * 获取tree权限列表
 * @returns
 */
export const getTreeListAPI = ()=>{
    return request<RoleData[]>('/park/sys/permision/all/tree');
  }

  /**
 * 查询当前角色详情-权限和分配人数
 * @returns
 */
export const getRoleDetailAPI = (roleId: number) =>{
    return request<RoleDetail>(`/park/sys/role/${roleId}`)
  }

  /**
 * 获取角色成员列表
 * @returns
 */
export const getRoleUserAPI = (roleId: number,params?:PageParams) => {
  return request<RoleUserData>(`/park/sys/roleUser/${roleId}`,'GET',params)
}

/**
 * 角色管理-添加角色
 * @param data 
 * @returns 
 */
export const createRoleUserAPI = (data: RoleParams) => {
  return request('/park/sys/role', 'POST', data)
}
/**
 * 角色管理-编辑角色
 * @param data 
 * @returns 
 */
export const editRoleUserAPI = (data: RoleParams) => {
  return request('/park/sys/role', 'PUT', data)
}

/**
 * 角色管理-删除角色
 * @param data 
 * @returns 
 */
export const delRoleUserAPI = (roleId: number) => {
  return request(`/park/sys/role/${roleId}`, 'DELETE')
}


